<fieldset id="fd1" style="width:80%;margin:5px;">
	<legend><span>工单信息查询</span></legend>
	<div class="fieldset-body">
		<table class="form-table" border="0" cellpadding="1" cellspacing="2">
			<tr>
				<td class="form-label" style="width:80px;">工单类型:</td>
				<td style="width:100px"><input id="types" class="mini-combobox" textField="name" valueField="id" data="JS.CONST[5]" allowInput="true" style="width:100%;" /></td>
				<td class="form-label" style="width:80px;">工单编号:</td>
				<td style="width:100px"><input id="name" class="mini-textbox" emptyText="请输入工单编号" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">备用编号:</td>
				<td style="width:100px"><input id="order_id" class="mini-textbox" emptyText="请输入备用编号" style="width:100%;"/></td>
				<td style="width:80px;"><a class="mini-button" id="search" iconCls="icon-search">查询...</a></td>
			</tr>
		</table>
	</div>
</fieldset>
<div class="mini-toolbar" style="padding:0px;margin:6px 0px 0px 0px;border-bottom:0;width:100%;"><table style="width:100%;"><tr><td style="width:100%;">操作记录列表</td></tr></table></div>
<div id="grid1" class="mini-datagrid" allowAlternating="true" idField="id" pageSize="20" style="width:100%;height:78%;" url="/customer/customerList" >
	<div property="columns">
		<div type="indexcolumn" headerAlign="center">编号</div>
		<div field="id" width="60" headerAlign="center" allowSort="true">工单编号</div>
		<div field="types" width="80" headerAlign="center" allowSort="true" align="center">工单类型</div>
		<div field="title" width="80" headerAlign="center">标题</div>
		<div field="id" name="schedule" width="200" headerAlign="center">进度</div>
		<div field="remark" width="200" headerAlign="center">备注<input property="editor" class="mini-textarea" emptyText="请输入备注" style="width:100%;height:40px;"/></div>
		<div field="status" width="100" headerAlign="center" allowSort="true">状态</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
var urlDel = "/customer/customerDel";
var urlUpd = "/customer/customerUpd";
var grid = mini.get("grid1");
grid.load({types:1});
var grid2 = mini.get("grid2");
grid2.load({types:1});

grid.on("drawcell",function(e){
    var record = e.record;
    var column = e.column;
    var field = e.field;
    var value = e.value;

    if (column.name == "schedule") {
        e.cellHtml = '<div class="progressbar">'
                        + '<div class="progressbar-percent" style="width:' + value + '%;"></div>'
                        + '<div class="progressbar-label">' + value + '%</div>'
                    +'</div>';
    }
});

grid2.on("drawcell",function(e){
    var record = e.record;
    var column = e.column;
    var field = e.field;
    var value = e.value;

    if (column.name == "schedule") {
        e.cellHtml = '<div class="progressbar">'
                        + '<div class="progressbar-percent" style="width:' + value + '%;"></div>'
                        + '<div class="progressbar-label">' + value + '%</div>'
                    +'</div>';
    }
});

$("#search").click(function(){
	grid.load({
		       id:mini.get("id").getValue(),
		       types:mini.get("types").getValue(),
		       order_id:mini.get("order_id").getValue()
		    });
});

$("#buttonStart").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要启用这个顾客吗？",function(){
			$.post('/customer/stopStart',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:1,user:mini.get("user").getValue(),name:mini.get("name").getValue()});
				}else{
					parent.$.dooDialog.alert('启用顾客失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#buttonEnd").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要禁用这个顾客吗？",function(){
			$.post('/customer/stopEnd',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:1,user:mini.get("user").getValue(),name:mini.get("name").getValue()});
				}else{
					parent.$.dooDialog.alert('禁用顾客失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#buttonReload").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		parent.$.dooDialog.confirm("你确定要重置这个顾客的密码吗？",function(){
			$.post('/customer/pwdReload',{id:row.sid},function(data){
				if(data.code=='OK'){
					grid.load({types:1,user:mini.get("user").getValue(),name:mini.get("name").getValue()});
					parent.$.dooDialog.alert('密码重置成功！');
				}else{
					parent.$.dooDialog.alert('密码重置失败！');
					return false;
				}
			},'json');
		});
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});

$("#buttonDown").click(function(){
	var row = grid.getSelected();
	if (row != null) {
		$.post('/customer/typesDown',{id:row.cid},function(data){
			if(data.code=='OK'){
				grid.load({types:1,user:mini.get("user").getValue(),name:mini.get("name").getValue()});
				parent.$.dooDialog.alert('客户降级为潜在客户成功！');
			}else{
				parent.$.dooDialog.alert('客户降级为潜在客户失败！');
				return false;
			}
		},'json');
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
});
</script>